|
|
- Robocode -- API Overview
- There's also several events which Robot automatically registers with, including onHitByBullet, onBulletHit, onScannedRobotEvent, onRobotDeath
- Some of these are pretty critical; they attach your "brain" to your "eyes & ears"
- Let's say you wanted to fire at a robot every time you see one:
public class BeginnerRobot extends Robot {
public run() {
while (true) {
ahead(100); turnLeft(180);
}
}
public onScannedRobotEvent(ScannedRobotEvent e) {
fire(1);
}
}
|
|